<template>
	<view class="profile">
		<!-- 个人信息 -->
		<view class="profile_info" @click="setPeopleDataClick">
			<view class="info_img">
				<image :src="userInfo.photo_url ? userInfo.photo_url : BASE_IMG_URL+'headImg.png'"   mode="scaleToFill"></image>
			</view>
			<view class="info_con">
				<view>{{userInfo.trueName}}<text>{{userInfo.post}}</text></view>
				<view>{{userInfo.mobile}}</view>
			</view>
			<view class="iconfont icon-arrows_right" ></view>
		</view> 
		<view class="warpbox dataPre">
			<view class="pre_list">
				<view class="pre_title">
					我的业绩(当月)
				</view>
			</view>
			<view class="pre_content"> 
				<view class="content_item" @click="sale_achieve(userInfo.id)">
					<view>{{personAchieve.saletotalAmount||0}}</view>
					<view>销售业绩</view>
				</view>
				<view class="content_item" @click="consume_achieve(userInfo.id)">
					<view>{{personAchieve.consumetotalAmount || 0}}</view>
					<view>耗卡业绩</view>
				</view> 
				<view class="content_item"  @click="shougongfei(userInfo.id)">
					<view>{{personAchieve.manualtotalAmount || 0}}</view>
					<view>手工费</view>
				</view> 
				<view class="content_item" v-if="false">
					<view>{{personAchieve.newcustomertotalAmount || 0}}</view>
					<view>新客</view>
				</view> 
			</view>
		</view>
		<view class="warpbox">
			<view class="warptitle">工作</view>
			<view class="fun_box">
				<view class="fun_fir" v-if="false" @click="toWaterCustomer">
					<image :src="BASE_IMG_URL+'user_btn_1.png'" mode="scaleToFill"></image>
					<view>公海</view>
				</view>
				<view class="fun_fir" @click="toRecord">
					<image :src="BASE_IMG_URL+'user_btn_2.png'" mode="scaleToFill"></image> 
					<view>跟进</view>
				</view>
				<view class="fun_fir" @click="toCustomer">
					<image :src="BASE_IMG_URL+'user_btn_3.png'" mode="scaleToFill"></image>
					<view>客户</view>
				</view>
				<view class="fun_fir" @click="appoint_list">
					<image :src="BASE_IMG_URL+'user_btn_4.png'" mode="scaleToFill"></image>
					<view>预约</view>
				</view>
				<view class="fun_fir" @click="workreport">
					<image :src="BASE_IMG_URL+'user_btn_5.png'" mode="scaleToFill"></image>
					<view>日报</view>
				</view>
			</view>
		</view>
		<view class="warpbox" v-if="false">
			<view class="warptitle">工作</view>
			<view class="fun_box">
				<view class="fun_fir" @click="workreport">
					<image :src="BASE_IMG_URL+'user_btn_12.png'" mode="scaleToFill"></image>
					<view>工作报告</view>
				</view>
				<view class="fun_fir" @click="affiche">
					<image :src="BASE_IMG_URL+'user_btn_6.png'" mode="scaleToFill"></image>
					<view>公告</view>
				</view>
				
				<view class="fun_fir" @click="remind">
					<image :src="BASE_IMG_URL+'user_btn_7.png'" mode="scaleToFill"></image>
					<view>审批</view>
				</view>
				<view class="fun_fir" @click="addChuchai">
					<image :src="BASE_IMG_URL+'user_btn_8.png'" mode="scaleToFill"></image>
					<view>外勤签到</view>
				</view>
				<view class="fun_fir" @click="toRecord">
					<image :src="BASE_IMG_URL+'user_btn_9.png'" mode="scaleToFill"></image>
					<view>跟进记录</view>
				</view>
				<view class="fun_fir" @click="jumpSign">
					<image :src="BASE_IMG_URL+'user_btn_10.png'" mode="scaleToFill"></image>
					<view>签到记录</view>
				</view>
				<view class="fun_fir" @click="toClientele">
					<image :src="BASE_IMG_URL+'user_btn_11.png'" mode="scaleToFill"></image>
					<view>重点关注</view>
				</view>
				<view class="fun_fir" @click="workTrend">
					<image :src="BASE_IMG_URL+'user_btn_13.png'" mode="scaleToFill"></image>
					<view>工作动态</view>
				</view>
			</view>
		</view>
		<view class="warpbox" v-if="false && roleType == 1 || roleType == 2">
			<view class="warptitle">管理</view>
			<view class="fun_box">
				<view class="fun_fir" @click="jumpStaffList" v-if="roleType == 1 || roleType == 2">
					<image :src="BASE_IMG_URL+'user_list.png'" mode="scaleToFill"></image>
					<view>员工列表</view>
				</view>
			</view>
		</view>
		
		
		<view class="profile_fun">
			<!-- #ifdef MP-WEIXIN || H5 -->
			<view class="profile_item" @click="toBindAccount">
				<view class="itemleft">
					<image :src="BASE_IMG_URL+'bangding.png'" class="leftimg"  mode="scaleToFill"></image>
					<view class="lxs_font">第三方账号绑定</view>
				</view>
				<view class="iconfont icon-arrows_right"></view>
			</view>
			<!-- #endif -->
			<view class="profile_item" @click="toIdea">
				<view class="itemleft">
					<image :src="BASE_IMG_URL+'yijianfankui.png'" class="leftimg" mode="scaleToFill"></image>
					<view class="lxs_font">意见反馈</view>
				</view>
				<view class="iconfont icon-arrows_right"></view>
			</view>
			
			<view class="profile_item" @click="toOut">
				<view class="itemleft">
					<image :src="BASE_IMG_URL+'user_out.png'" class="leftimg" mode="scaleToFill">
					<view class="lxs_font">退出登录</view>
				</view>
				<view class="iconfont icon-arrows_right"></view>
			</view>
		</view>
		
		<!-- 底部导航 -->
		<uniTabbar v-if="tipNumber || tipNumber==0" :tipNumber="tipNumber"></uniTabbar>
	</view>
</template>
	 
<script>
	import uniTabbar from '@/components/tabbar/tabbar.vue'
	import {pageJumps} from "./profile_page_iumps.js";
	import { netGetUserInfo ,netGetStaffArchieveData} from '@/api/index.js'
	import { netAgentList } from '@/api/clues.js'
	import { netOutLogin } from '@/api/login'
	import { BASE_IMG_URL } from '@/util/api.js'
	import * as crmjs from "@/pagesA/crm/crm_page_jumps.js";
	import * as newsjs from "@/pages/news/news_page_jumps.js";
	
	export default {
		mixins:[pageJumps,crmjs.pageJumps,newsjs.pageJumps],
		components:{
			uniTabbar
		},
		data() {
			return {
				userInfo:{},
				roleType:1,
				rules:[],
				personAchieve:{
					manualtotalAmount: 0,
					consumetotalAmount: 0,
					saletotalAmount: 0,
					newcustomertotalAmount: 0, 
				},
				tipNumber:null,
				BASE_IMG_URL:BASE_IMG_URL,
			}
		},
		onShow() {
			this.roleType = uni.getStorageSync('roleType')
			this.rules = uni.getStorageSync('rules')
			
			this.getTip()
		},
		methods: {
			getTip(){
				netAgentList().then(res=>{
					// uni.setStorageSync('token',res.data.userinfo.token)
					// uni.setStorageSync('roleType',res.data.userinfo.role_type)
					// uni.setStorageSync('rules',res.data.userinfo.rules)
					this.tipNumber = res.data.total
					this.getInfo()
				})
			},
			getInfo() {
				netGetUserInfo().then(res=>{
					this.userInfo = res.data
				})
				
				netGetStaffArchieveData().then(res=>{ 
					this.personAchieve = res.data
				})
			},
			// 个人资料
			setPeopleDataClick() {
				uni.navigateTo({
					url:'/pages/profile/mySet/setPersonData/setPersonData'
				})
			},
			//员工列表 
			jumpStaffList() {
				uni.navigateTo({
					url:'/pages/profile/staff/stafflist/index'
				})
			},
			//审核  员工  列表
			jumpExamineStaff() {
				uni.navigateTo({
					url:'/pages/profile/staff/examinestaff/index'
				})
			},
			// 企业信息
			toEnterprise(id) {
				console.log(id,'id')
				uni.navigateTo({
					url: '/pages/profile/enterpriseInfo/enterpriseInfo?id?' +id
				})
			},
			//第三方账号绑定
			toBindAccount() {
				console.log('----')
				uni.navigateTo({
					url:'/pagesA/user/bindaccount',
					fail:(err)=>{
						console.log(err)
					}
				})
			},
			//退出登录
			toOut() {
				uni.showModal({
					title:'提示',
					content:'请确认是否退出登录?',
					success:(res)=> {
						if(res.confirm){
							netOutLogin().then(res=>{
								uni.showToast({
									title:'退出登录',
									icon:'none'
								})
								setTimeout(()=>{
									uni.redirectTo({
										url:'/pages/public/login'
									})
								},2000)
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.dataPre {
		background-color: #fff;
		border-radius: 10rpx;
		box-sizing: border-box;
		padding: 20rpx 0 40rpx;
		margin: 0 24rpx 30rpx 24rpx;
		border-radius: 20rpx;
		box-shadow: 1rpx 1rpx 10rpx rgba(0, 0, 0, 0.1);
	
		.pre_content {
			background-color: #fff;
			display: flex;
			flex-wrap: wrap;
	
			.content_item {
				width: 33%;
				text-align: center;
	
				:first-child {
					font-size: 32rpx;
					font-weight: 600;
					margin-top: 26rpx;
					margin-bottom: 10rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
	
				:last-child {
					font-size: 24rpx;
					padding: 0 20rpx;
					color: #000;
				}
			}
		}
	}
	.message_num {
		width: 20rpx;
		height: 20rpx;
		border-radius: 20rpx;
		color: #fff;
		position: relative;
		top: 0;
		right: 0;
	}
	.color{
		background: #fff;
	}
	.colore{
		background: #f00;
	}
	.warpbox{
		width:702rpx;
		box-sizing: border-box;
		background:#fff;
		border-radius: 20rpx;
		margin:0 auto 30rpx;
		padding:30rpx;
		box-shadow: 1rpx 1rpx 10rpx rgba(0,0,0,0.1);
		.warptitle{
			font-size:26rpx;
			color:#333;
			margin-bottom:30rpx;
		}
		.fun_box{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			flex-wrap:wrap;
			.fun_fir{
				flex-shrink: 0;
				background:#fff;
				border-radius: 10rpx;
				text-align: center;
				width:142rpx;
				height:115rpx;
				margin-right:24rpx;
				margin-bottom:24rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				font-size:24rpx;
				color:#000;
				&:nth-child(4n){
					margin-right:0;
				}
				image{
					width:50rpx;
					height:50rpx;
					margin-bottom:15rpx;
				}
			}
		}
	}
.profile {
	// 个人信息
	.profile_info {
		background-color: #fff;
		display: flex;
		padding: 50rpx 20rpx 50rpx 60rpx;
		border-bottom: 1rpx solid #EAEAEA;
		margin-bottom: 30rpx;
		.info_img {
			width: 150rpx;
			image {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
			}
		}
		.info_con {
			flex: 1;
			margin-top: 20rpx;
			:first-child {
				font-size: 28rpx;
				margin-bottom: 15rpx;
			}
			text {
				font-size: 24rpx;
				margin-left: 10rpx;
				color: #999;
			}
			:last-child {
				color: #999;
			}
		}
		.icon-arrows_right {
			width: 40rpx;
			margin-top: 47rpx;
			font-size: 40rpx;
		}
	}
	// 功能模块
	.profile_fun {
		background-color: #fff;
		.profile_item {
			display: flex;
			background:#fff;
			color:#666;
			padding: 0 30rpx;
			justify-content: space-between;
			border-bottom:1rpx solid #f5f5f5;
			height: 110rpx;
			line-height: 110rpx;
			font-size: 28rpx;
			.itemleft{
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.leftimg{
					height:25px;
					width:25px;
					margin-right:25rpx;
				}
			}
		}
		button::after{
			border:none;
		}
	}
}

.iconfont{
	padding-top: 4px;
}
.lxs_font{
	font-size: 14px;
}
</style>
